package com.mmall.concurrency.immutable;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Collections;
import java.util.Map;

/**  基本变量和引用变量编译报错
 *   引用变量不可以再指向， 但是可以修改里面的值
 */
@Slf4j
public class GuavaTest {

    public static final ImmutableList<Integer> list = ImmutableList.of(1,2,4,6,2);
    public static final ImmutableSet<Integer> set = ImmutableSet.copyOf(list);

    // map 有点特殊
    public static final ImmutableMap<Integer,Integer> map = ImmutableMap.of(1,2,3,4,5,6);
     public static final ImmutableMap<Integer,Integer> map2 = ImmutableMap.<Integer,Integer>builder().put(11,22).put(33,44).build();

    public static void main(String[] args) {
        // list.add(7);   过期--
        // set.add(3);     过期--
        // map.put(1,3);    过期--
        System.out.println(map2.get(11));
        System.out.println(map2.containsKey(33));
        System.out.println(map2.hashCode());
        System.out.println(map2.toString());
    }

}
